package com.xiaotu.storage;

import java.util.Date;

import org.springframework.stereotype.Component;

import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.common.util.SepratorUtil;
import com.xiaotu.storage.converter.AConverter;
import com.xiaotu.storage.converter.ConverterFactory;
import com.xiaotu.storage.model.CacheDataModel;

import net.sf.json.JSONObject;
/***
 * 猫眼电影基础信息转储
 * @author Mr.zhang
 *
 */
@Component("MovieInfoSupplementStorageProcessor")
public class MovieInfoSupplementStorageProcessor extends AHSetStorageProcessor{

	public static final String[] FIELD_ARR = new String[]{
			"id","dataid",
			"tvname","director",
			"actor","actorRole",
			"productionCompany","issueCompany",
			"jointIssueCompany","publishCompany",
			"otherCompany","introduction",
			"status","supplement",
			"onlineDate","offlineDate",
			"collecttime","englishName",
			"timeLength","playType",
			"showingArea",
			"label","area",
			"jointPublishCompany","marketCompany",
			"posterProductionCompany","trailerProductionCompany",
			"propagandaCompany","showingDate",
			"directorEnglishName","actorEnglishName",
			"screenWriter","screenwriterEnglishName",
			"producer","producerEnglishName",
			"photographer","photographerEnglishName",
			"publisher","publisherEnglishName",
			"issuer","issuerEnglishName",
			"tvid","tvType","resourceSiteId","cycleStatus",
			"imageurl","sets"};
	
	private static final String[] CONVERT_ARR = new String[]{
			AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,
			AConverter.STRING_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRING_CONVERT,
			AConverter.INTEGER_CONVERT,AConverter.INTEGER_CONVERT,
			AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,
			AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,
			AConverter.STRING_CONVERT,AConverter.STRING_CONVERT,
			AConverter.STRING_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRING_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRINGARRAY_CONVERT,AConverter.STRINGARRAY_CONVERT,
			AConverter.STRING_CONVERT,AConverter.INTEGER_CONVERT,AConverter.STRING_CONVERT
			,AConverter.INTEGER_CONVERT,
			AConverter.STRING_CONVERT,AConverter.STRING_CONVERT};
	
	private static final boolean[] THROW_ARR = new boolean[]{true ,true, true, true, true, true,
			true ,true, true, true, true, true,
			true ,true, true, true, true, true, 
			true, true, true, true, true,
			true, true, true, true, true,true,
			true, true, true, true, true,true,
			true, true, true, true, true,true,
			true,true,true,true,true,true};
	
	@Override
	protected String getRedisKey(Date date) {
		return DataRedisKeyUtils.getKey(Constants.DataRedisKey.MOVIE_INFO_SUPPLEMENT_YYYYMMDD, date);
	}

	@Override
	public String process(JSONObject target, CacheDataModel cacheData, Date date) {
		 return this.list2CSVLine(ConverterFactory.convert(target, FIELD_ARR, CONVERT_ARR,
	                THROW_ARR),SepratorUtil.SEP_PIPE);
	}

	@Override
	public String getDataType() {
		return Constants.PageDataType.TV_BASICINFO;
	}

	@Override
	public String getTaskType() {
		return Constants.PageDataType.BASICINFO;
	}
	
}
